<h1 class="page-header">
    <small>编辑核销人员</small>
</h1>
<hr/>
<div class="panel panel-inverse" data-sortable-id="form-stuff-1">
    <div class="panel-heading">
        <h4 class="panel-title">核销人员信息表单</h4>
    </div>
    <div class="panel-body">
        <form class="form-horizontal" id="confirmerForm" name="confirmerForm" action="" method="post">
            <div class="form-group">
                <input type="hidden" id="id"  name="id" placeholder="核销人员id" value="${confirmer.id}">
                <label class="col-md-3 control-label">*姓名</label>

                <div class="col-md-9">
                    <input type="text" id="realName" class="form-control" name="realName" placeholder="姓名"
                           maxlength="20" value="${confirmer.realName}" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">*手机号</label>

                <div class="col-md-9">
                    <input type="text" id="mobile" class="form-control" name="mobile" placeholder="手机号"
                           maxlength="20" value="${confirmer.mobile}" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">归属店铺</label>
                <div class="col-md-9">
                    <select class="form-control" name="storeId" id="storeId">
                        <option value="0" <#if 0 == confirmer.storeId > selected</#if> >全部</option>
                        <#if storeList?has_content && storeList?exists>
                        <#list storeList as pf>
                        <option value="${pf.id}" <#if pf.id == confirmer.storeId > selected</#if> >${pf.name}</option>
                        </#list>
                        </#if>
                </select>
            </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">状态</label>
                <div class="col-md-9">
                    <select class="form-control" name="auditedStatus" id="auditedStatus">
                        <option value="A" <#if confirmer.auditedStatus == "A" > selected</#if>>启用</option>
                        <option value="N" <#if confirmer.auditedStatus == "N" > selected</#if>>禁用</option>
                        <option value="U" <#if confirmer.auditedStatus == "U" > selected</#if>>待审核</option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label"></label>
                <div class="col-md-9">
                    <button type="button" id="submitButton" class="btn btn-sm btn-success">提交</button>
                    <button type="button" class="btn btn-sm btn-danger"
                            onclick="getData('${rc.contextPath}/backend/confirmer/queryList','displayArea')">返回
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="application/javascript">

    jQuery.validator.addMethod("isMobile", function(value, element) {
        var length = value.length;
        var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
        return this.optional(element) || (length == 11 && mobile.test(value));
    }, "请正确填写手机号码");

    $(function () {
        $('#submitButton').click(function () {
            $('#confirmerForm').submit();
        });

        $('#confirmerForm').validate({
            rules: {
                realName: {
                    required : true,
                    maxlength : 20
                },
                mobile: {
                    required : true,
                    minlength : 11,
                    isMobile : true
                }

            },
            messages: {
                realName: {
                    required :  "姓名需要填写",
                    maxlength : "不能大于20个字符"
                },
                mobile: {
                    required : "请输入手机号",
                    minlength : "不能小于11个字符",
                    isMobile : "请正确填写手机号码"
                }
            },
            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
            },
            submitHandler: function () {
                postDataByFormParams('${rc.contextPath}/backend/confirmer/doEdit', 'displayArea', 'confirmerForm');
            }
        })
    })
</script>

